package br.com.gecandango.portlets;

import java.io.IOException;

import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import br.com.gecandango.service.ContatoService;
import br.com.gecandango.service.EquipeService;
import br.com.gecandango.service.SecaoService;
import br.com.gecandango.service.SocioService;

import com.liferay.portlet.StrutsPortlet;

public class SavePortlet extends StrutsPortlet {
	static ApplicationContext context = new ClassPathXmlApplicationContext(
			"applicationContext.xml");

	public void doView(RenderRequest req, RenderResponse res)
			throws IOException, PortletException {
		req.setAttribute("socios", getSocioService().list());
		
		req.setAttribute("secoes", getSecaoService().list());
		
		req.setAttribute("equipes", getEquipeService().list());
		
		req.setAttribute("contatos", getContatoService().list());
		
		super.doView(req, res);
	}
	static SocioService getSocioService() {
		return (SocioService) context.getBean("SocioService");
	}
	static SecaoService getSecaoService() {
		return (SecaoService) context.getBean("SecaoService");
	}
	static EquipeService getEquipeService() {
		return (EquipeService) context.getBean("EquipeService");
	}
	static ContatoService getContatoService() {
		return (ContatoService) context.getBean("ContatoService");
	}
}
